package org.gdstash.character;

import org.gdstash.db.DBEngineTagText;
import org.gdstash.util.GDColor;
import org.gdstash.util.GDMsgFormatter;

public class GDCharSummary {
    private String charName;
    private byte sex;
    private String classID;
    private int level;
    private boolean hardcore;
    private boolean expansionAoM;
    private boolean expansionFG;
    private boolean isInMainQuest;
    private String className;

    public GDCharSummary(final GDCharHeader header, final GDCharInfo info) {
        this.charName = header.getCharName();
        this.sex = header.getSex();
        this.classID = header.getClassID();
        this.level = header.getLevel();
        this.hardcore = header.isHardcore();
        this.expansionAoM = header.isAsheshOfMalmouthChar();
        this.expansionFG = header.isForgottenGodsChar();
        this.isInMainQuest = info.isInMainQuest();
        this.className = this.parseClassName();
    }

    public String getCharName() {
        return this.charName;
    }

    public byte getSex() {
        return this.sex;
    }

    public String getClassName() {
        return this.className;
    }

    public int getLevel() {
        return this.level;
    }

    public boolean isHardcore() {
        return this.hardcore;
    }

    public String getExpansionInfo() {
        String s = null;
        if (this.expansionFG) {
            s = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_CHAR_FG_SHORT");
            s = GDColor.HTML_COLOR_CHAR_FG + s + "</font>";
        } else if (this.expansionAoM) {
            s = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_CHAR_AOM_SHORT");
            s = GDColor.HTML_COLOR_CHAR_AOM + s + "</font>";
        } else {
            s = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_CHAR_GD_SHORT");
            s = GDColor.HTML_COLOR_CHAR_GD + s + "</font>";
        }
        return s;
    }

    public boolean isInMainQuest() {
        return this.isInMainQuest;
    }

    private String parseClassName() {
        DBEngineTagText tt = null;
        String s = "???";
        if (this.classID != null) {
            tt = DBEngineTagText.get(this.classID);
        }
        if (tt != null) {
            if (this.sex == 1) {
                s = tt.getText(0);
            } else {
                s = tt.getText(1);
            }
        }
        return s;
    }

    public void updateClassName() {
        this.className = this.parseClassName();
    }
}
